/**
 * @fileoverview Giant Interective Group, Inc. Javascript Library v2.0.3.
 * 年月日级联列表控件。
 * <pre>
 * Copyright (C) 2004-2009 Giant Interective Group, Inc. All rights reserved.
 * 版权所有 2004-2009 上海巨人网络科技有限公司
 * </pre>
 * 
 * @version 2.0.3, 2009-05-22 11:40:52
 * @author  Fuchun
 */

(function($) {

/** 星座列表。
 * @type Object */
giant.ui.astros = {
	'1': "白羊座",
	'2': "金牛座",
	'3': "双子座",
	'4': "巨蟹座",
	'5': "狮子座",
	'6': "处女座",
	'7': "天秤座",
	'8': "天蝎座",
	'9': "射手座",
	'10': "摩羯座",
	'11': "水瓶座",
	'12': "双鱼座"
};
giant.ui.astrosCss = {
	'1': 'guide-astro g-aries',
    '2': 'guide-astro g-taurus',
    '3': 'guide-astro g-gemini',
    '4': 'guide-astro g-cancer',
    '5': 'guide-astro g-leo',
    '6': 'guide-astro g-virgo',
    '7': 'guide-astro g-libra',
    '8': 'guide-astro g-scorpio',
    '9': 'guide-astro g-sagittarius',
    '10': 'guide-astro g-capricorn',
    '11': 'guide-astro g-aquarius',
    '12': 'guide-astro g-pisces'
};
	
/** 根据月份变换天数 */
giant.ui.changeDate = function(obj) {
	giant.ui.removeDay();
	switch (parseInt($(obj).val())){
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		giant.ui.getDayOfMonth(31);
		break;
	case 2:
		giant.ui.getDayOfMonth(29);
		break;
	case -1:
		giant.ui.getDayOfMonth(0);
		break;
	default:
		giant.ui.getDayOfMonth(30);
		break;	
	}
};

/** 得到指定月份的天数 */
giant.ui.getDayOfMonth = function(m) {
	var arr = [];
	for(var i=1; i<=m; i++){
		arr.push("<option value='"+i+"'>"+i+"</option>");
	}
	$.combobox({id:'cmb_date'}).getJComboBox().append(arr.join());
};

/** 移除天数 */
giant.ui.removeDay = function() {
	this.jDay = $.combobox({id:'cmb_date'});
	//var first = this.jDay.getJComboBox().find('option:first');
	this.jDay.remove();
	//first.appendTo(this.jDay.getJComboBox());
	$('#cmb_date').append('<option value="-1">不限</option>');
	$('#txt_userSearch_astro').val('');
	$('#div_userSearch_astro')[0].className = '';
	$('#div_userSearch_astro').text('');
};

/** 根据月日得到星座 */
giant.ui.getAstro = function(m, d) {
	if(parseInt(d) < 10)
        d = '0' + d;
	var b = Number(m + '' + d);
	if(b >= 321 && b <= 419) {
		return '1';
	} else if(b >= 420 && b <= 520) {
		return '2';
	} else if(b >= 521 && b <= 621) {
		return '3';
	} else if(b >= 622 && b <= 722) {
		return '4';
	} else if(b >= 723 && b <= 822) {
		return '5';
	} else if(b >= 823 && b <= 922) {
		return '6';
	} else if(b >= 923 && b <= 1023) {
		return '7';
	} else if(b >= 1024 && b <= 1122) {
		return '8';
	} else if(b >= 1123 && b <= 1221) {
		return '9';
	} else if((b >= 1222 && b <= 1231) ||(b >= 101 && b <= 119)) {
		return '10';
	} else if(b >= 120 && b <= 218) {
		return '11';
	} else if(b >= 219 && b <= 320) {
		return '12';
	}
	return '';
};

giant.ui.changeAstro = function() {
	//this.jMonth = $.combobox({id:'cmb_month'});
	//this.jDate = $.combobox({id:'cmb_date'});
	//alert($('#cmb_month').val()+'月'+$('#cmb_date').val()+'日');
	
	var month = $('#cmb_month').val();
	var date = $('#cmb_date').val();
	var astro = giant.ui.getAstro(month, date);
	$('#txt_userSearch_astro').val(astro);
    $('#div_userSearch_astro')[0].className = giant.ui.astrosCss[astro];
    $('#div_userSearch_astro').text(giant.ui.astros[astro]);
};

})(jQuery);